<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	var receiveMemberId = "${param.receiveMemberId}";
	var sendMemberId = "${sessionScope.mvo.memberId}";
	var adminSession =  "${sessionScope.advo.adminId}";
		if(sendMemberId==null&&adminSession==null){
			alert("로그인 해야 쪽지 보낼 수 있어염");
			self.close();
		};		
		if(receiveMemberId==sendMemberId){
			alert("자신에게 쪽지를 보낼 수는 없습니다.");
			self.close();
		};
	$("#sendMessageForm").submit(function(){		
		var messagTitle = $("#messageTitle").val();
		var messageContent = $("#messageContent").val();		
		if(messagTitle==""){
			alert("제목을 입력해 주세요.");
			return false;
		}else if(messageContent==""){
			alert("내용을 입력해 주세요.");
			return false;
		}	
		alert(receiveMemberId+"님께 쪽지를 성공적으로 보냈습니다.");
		self.close();
	});	
	$("#cancelMsg").click(function(){
		self.close();
	});	
});//ready
</script>
</head>
<body>
<form id="sendMessageForm" method="post" action="${initParam.root}member/sendMessage.do">
<input type="hidden" name="receiveMemberId" value="${param.receiveMemberId}" >


<table class="list">
		<tr>
			<td>To : ${param.receiveMemberId } </td>		
			<c:choose>
				<c:when test="${sessionScope.advo.adminId!=null}">
					<td>From : ${sessionScope.advo.adminId} </td>		
					<input type="hidden" name="sendMemberId" value="${sessionScope.advo.adminId}" >
				</c:when>
				<c:otherwise>
					<td>From : ${sessionScope.mvo.memberId} </td>	
					<input type="hidden" name="sendMemberId" value="${sessionScope.mvo.memberId}" >
				</c:otherwise>
			</c:choose>
			
	  </tr>
	  <tr>
	  	<td colspan="2">Title <input type="text" id="messageTitle" name="messageTitle" width="50"></td>
	  </tr>
	    <tr>
	  	<td>Content</td><td><pre> <textarea rows="10" cols="40" name="messageContent" id="messageContent"></textarea></pre></td>
	  </tr>
	<tr>
			<td colspan="2"  align="right"><input type="submit" id="sendMsg" value="쪽지보내기">
			<input type="button" id="cancelMsg" value="취소"></td>
  	</tr>
		</table>
</form>
</body>
</html>